<?php

class Xml_Controller extends AppController
{
    var $uses = array("Post", "Track", "Site");
    
    function latest()
    {
        echo 'text';
        $tracks = $this->Track->findAll(null, null, "`Post`.`date` DESC", 50);
        $xml = new DomDocument();        
        $root = $xml->createElement('xml');
        
        foreach ($tracks as &$track)
        {
            $track = $this->Track->format($track);
            $track_tag = $xml->createElement('track');
            $path = $xml->createElement('path', '/tracks/'.$track['Track']['id'].'.jpg');
            $title = $xml->createElement('title', ucwords($track['Track']['name']));
            $track_tag->appendChild($path);
            $track_tag->appendChild($title);
            $root->appendChild($track_tag);
            
        }
        
        echo $root->saveXML();
        exit;     
    }
    
}
?>